from manager import AIManager
from assistant_types import (
    TextAssistant, ImageAssistant, DataAnalysisAssistant,
    TranslationAssistant, VoiceAssistant
)


def main():
    manager = AIManager()

    manager.add_assistant(VoiceAssistant("1", "小智", "1.2", True, 85), silent=True)
    manager.add_assistant(TextAssistant("2", "文助", "2.0", True, 92), silent=True)
    manager.add_assistant(ImageAssistant("3", "图灵", "1.5", False, 88), silent=True)
    manager.add_assistant(DataAnalysisAssistant("4", "数析", "1.0", True, 79), silent=True)
    manager.add_assistant(TranslationAssistant("5", "译灵", "2.1", False, 95), silent=True)

    while True:
        print("""========== 卢奕含牌AI助手管理器 ==========
1. 查看所有AI助手列表
2. 根据ID查询助手详情
3. 添加新的AI助手
4. 根据ID修改助手信息
5. 删除AI助手（按ID）
6. 启动AI助手服务
7. 停止AI助手服务
8. 为AI助手分配任务
9. 显示系统统计信息
0. 退出系统
===================================""")
        choice = input("请选择操作: ")

        if choice == "1":
            manager.list_assistants()
        elif choice == "2":
            manager.show_details(input("请输入要查询的AI助手ID: "))
        elif choice == "3":
            id = input("请输入ID: ")
            name = input("请输入名称: ")
            print("助手类型：1-文本助手 2-图像助手 3-数据分析助手 4-翻译助手 5-语音助手")
            t = input("请选择类型编号: ")
            version = input("请输入版本号: ")
            online = input("是否在线？(1-是, 0-否): ") == "1"
            score = float(input("请输入能力评分(0-100): "))

            if t == "1":
                assistant = TextAssistant(id, name, version, online, score)
            elif t == "2":
                assistant = ImageAssistant(id, name, version, online, score)
            elif t == "3":
                assistant = DataAnalysisAssistant(id, name, version, online, score)
            elif t == "4":
                assistant = TranslationAssistant(id, name, version, online, score)
            elif t == "5":
                assistant = VoiceAssistant(id, name, version, online, score)
            else:
                print("类型选择无效。")
                continue

            manager.add_assistant(assistant)
        elif choice == "4":
            id = input("请输入ID: ")
            print("可修改属性: name,type,version,online,score")
            attr, value = input("请输入要修改的属性和值，用空格分割: ").split()
            manager.modify_assistant(id, attr, value)
        elif choice == "5":
            manager.delete_assistant(input("请输入要删除的AI助手ID: "))
        elif choice == "6":
            manager.start_service(input("请输入要启动的AI助手ID: "))
        elif choice == "7":
            manager.stop_service(input("请输入要停止的AI助手ID: "))
        elif choice == "8":
            id = input("请输入目标AI助手ID: ")
            task = input("请输入任务内容: ")
            manager.assign_task(id, task)
        elif choice == "9":
            manager.show_statistics()
        elif choice == "0":
            print("感谢使用 AI助手管理器，再见！")
            break
        else:
            print("无效选项，请重新输入。")


if __name__ == "__main__":
    main()
